package com.ja.openchat.ui.found;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ja.openchat.R;
import com.zy.openchat.core.model.circle.CircleTopicInfo;

import java.util.List;

public class CircleTopicAdapter extends BaseQuickAdapter<CircleTopicInfo, BaseViewHolder> {

    public CircleTopicAdapter(List<CircleTopicInfo> infos) {
        super(R.layout.item_circle_tag,infos);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CircleTopicInfo item) {
        helper.setText(R.id.titleText,String.format("#%s",item.name));
        View tag1 = helper.getView(R.id.tag1);
        View tag2 = helper.getView(R.id.tag2);
        View tag3 = helper.getView(R.id.tag3);
        View tag4 = helper.getView(R.id.tag4);
        View tag5 = helper.getView(R.id.tag5);
        tag1.setVisibility(View.GONE);
        tag2.setVisibility(View.GONE);
        tag3.setVisibility(View.GONE);
        tag4.setVisibility(View.GONE);
        tag5.setVisibility(View.GONE);
        if(item.ranking >=5){
            tag1.setVisibility(View.VISIBLE);
            tag2.setVisibility(View.VISIBLE);
            tag3.setVisibility(View.VISIBLE);
            tag4.setVisibility(View.VISIBLE);
            tag5.setVisibility(View.VISIBLE);
        }else if(item.ranking == 4){
            tag2.setVisibility(View.VISIBLE);
            tag3.setVisibility(View.VISIBLE);
            tag4.setVisibility(View.VISIBLE);
            tag5.setVisibility(View.VISIBLE);
        }else if(item.ranking == 3){
            tag3.setVisibility(View.VISIBLE);
            tag4.setVisibility(View.VISIBLE);
            tag5.setVisibility(View.VISIBLE);
        }else if(item.ranking == 2){
            tag4.setVisibility(View.VISIBLE);
            tag5.setVisibility(View.VISIBLE);
        }else if(item.ranking == 1){
            tag5.setVisibility(View.VISIBLE);
        }
    }
}
